<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <table border="1">
        <caption>个人信息</caption>
        <tr>
            <td>照片:</td>
            <td><img :src="p.url" style="width: 100px"></td>
        </tr>
        <tr>
            <td>姓名:</td>
            <td>{{p.name}}</td>
        </tr>
        <tr>
            <td>年龄:</td>
            <td>{{p.age}}</td>
        </tr>
        <tr>
            <td>好友们:</td>
            <td>
                <ul>
                    <li v-for="name in p.friends">{{name}}</li>
                </ul>
            </td>
        </tr>
    </table>
    <input type="button" value="请求数据" @click="f()">
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v = new Vue({
        el:"div",
        data:{
            p:{name:"xxx",age:0,url:"../m2.jpg",friends:["xxx","xxx"]}
        },
        methods:{
            f:function () {
                let person ={name:"赵兴",age:20,url:"../m3.jpg",friends:["刘德华","周显欣"]}
                //把模拟从服务器得到的数据赋值非和页面绑定的p变量 页面会发生改变
                v.p = person;
            }
        }
    })
</script>
</body>
</html>